package com.rags.chess.move;

import com.rags.chess.base.Coordinate;
import com.rags.chess.base.Piece;
import com.rags.chess.game.Game;
import com.rags.chess.game.GameHelper;
import com.rags.chess.pieces.King;

public abstract class Castling extends Move {
	public Castling(Game game, Coordinate start, Coordinate anEnd) {
		super(game, start, anEnd, null);
	}
	
	@Override
	protected String deriveNotation(Game game, Coordinate start, Coordinate end) {
		Piece startPiece = game.getPiece(start);
		if (!(startPiece instanceof King))
			throw new IllegalArgumentException(String.format("Cannot castle %s", startPiece.getClass().getSimpleName()));
		if (((King)startPiece).isMoved())
			throw new IllegalArgumentException("King has already moved, cannot castle");
		
		return null;
	}
	
	@Override
	protected boolean isInCheck(Game g, Coordinate begin, Coordinate finish) {
		if (super.isInCheck(g, begin, finish))
			return true;
		if (GameHelper.isInCheck(g, g.getMoveTurn()))
			return true;
		
		return false;
	}
}
